Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

302
Views
No se puede encontrar un elemento con el texto de marcador de posición "Buscar..." reactjs jest

Tengo un componente que usa async y await .

Estoy tratando de probar si se representa el marcador de posición para la entrada.

Sin embargo, siempre obtengo el error anterior.

Este es el componente:

 const [Loading, setLoading] = useState(false) const [name, setName] = useState(''); const [options, setOptions] = useState([]) const [data, setData] = useState(false) useEffect(() => { setLoading(true) const newUsers = async() => { const response = await fetch('https://jsonplaceholder.typicode.com/users') .then((res) => res.json()) .then((data) => { setData(data) }); }; newUsers(); }, []) if (!data) return <p className = 'text-center font-bold text-6xl' > Loading... < /p> if (!Loading) return <p className = 'text-center font-bold text-6xl' > Data loaded < /p> <input id = "input" className = 'w-96 h-16 border-1 shadow-lg rounded-lg' placeholder = "Search..." onChange = { e => handleChange(e.target.value) } value = { name } />

esta es la prueba

 test('input appears', async () => { await waitFor(() => { expect(screen.getByPlaceholderText('Search...')).toBeInTheDocument() }) })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que olvidaste devolver la entrada

 const [Loading, setLoading] = useState(false) const [name, setName] = useState(''); const [options, setOptions] = useState([]) const [data, setData] = useState(false) useEffect(() => { setLoading(true) const newUsers = async() => { const response = await fetch('https://jsonplaceholder.typicode.com/users') .then((res) => res.json()) .then((data) => { setData(data) }); }; newUsers(); }, []) if (!data) return <p className = 'text-center font-bold text-6xl' > Loading... < /p> if (!Loading) return <p className = 'text-center font-bold text-6xl' > Data loaded < /p> return ( // <---- Return <input id = "input" className = 'w-96 h-16 border-1 shadow-lg rounded-lg' placeholder = "Search..." onChange = { e => handleChange(e.target.value) } value = { name } /> );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!